package com.example.exp_3_javaweb;

import javax.servlet.ServletContext;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
import java.io.IOException;

@WebServlet("/requestscopeservlet")
public class RequestScopeServlet extends HttpServlet {
    @Override
    public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        Student student = new Student();
        student.setName("周经纬");
        student.setGender("男");
        student.setHobby(new String[]{"玩手机","吃东西"});
        //
        request.setAttribute("student",student);
        //
        HttpSession session = request.getSession();
        session.setAttribute("student",student);
        //
        ServletContext application = this.getServletContext();
        application.setAttribute("student",student);
        //
        //
        //request.getRequestDispatcher("receiveservlet").forward(request,response);
        //
        response.sendRedirect("receiveservlet2");
    }
}
